home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Info 1994 March
/
Internet Info CD-ROM (Walnut Creek) (March 1994).iso
/
networking
/
ip
/
ka9q
/
alpha.arc
/
ICMPDUMP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-02-18
|
2KB
|
76 lines
#include <stdio.h>
#include "global.h"
#include "mbuf.h"
#include "internet.h"
#include "icmp.h"
#include "trace.h"
/* Dump an ICMP header */
void
icmp_dump(bpp,source,dest,check)
struct mbuf **bpp;
int32 source,dest;
int check; /* If 0, bypass checksum verify */
{
struct icmp icmp;
int16 csum;
if(bpp == NULLBUFP || *bpp == NULLBUF)
return;
csum = cksum(NULLHEADER,*bpp,len_mbuf(*bpp));
ntohicmp(&icmp,bpp);
if(uchar(icmp.type) <= 16 && icmptypes[uchar(icmp.type)] != NULLCHAR)
printf("ICMP: %s",icmptypes[uchar(icmp.type)]);
else
printf("ICMP: type %u",uchar(icmp.type));
switch(uchar(icmp.type)){
case DEST_UNREACH:
if(uchar(icmp.code) <= 5)
printf(" %s",unreach[uchar(icmp.code)]);
else
printf(" code %u",uchar(icmp.code));
break;
case REDIRECT:
if(uchar(icmp.code) <= 3)
printf(" %s",redirect[uchar(icmp.code)]);
else
printf(" code %u",uchar(icmp.code));
break;
case TIME_EXCEED:
if(uchar(icmp.code) <= 1)
printf(" %s",exceed[uchar(icmp.code)]);
else
printf(" code %u",uchar(icmp.code));
break;
case PARAM_PROB:
printf(" pointer = %u",icmp.args.pointer);
break;
case ECHO:
case ECHO_REPLY:
case INFO_RQST:
case INFO_REPLY:
case TIMESTAMP:
case TIME_REPLY:
printf(" id %u seq %u",icmp.args.echo.id,icmp.args.echo.seq);
break;
}
if(check && csum != 0){
printf(" CHECKSUM ERROR (%u)",csum);
}
printf("\n");
/* Dump the offending IP header, if any */
switch(icmp.type){
case DEST_UNREACH:
case TIME_EXCEED:
case PARAM_PROB:
case QUENCH:
case REDIRECT:
printf("Returned ");
ip_dump(bpp,0);
}
}